package com.company.gas.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

import java.util.ArrayList;
/**
 * @author: Li Guangdi
 *
 */

@Configuration
@EnableSwagger2    //开启Swagger2
public class SwaggerConfig {

    //配置了Swagger的Docket的Bean实例
    @Bean
    public Docket docket(){
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .groupName("lgd")
                //.enable(false)  /*关闭Swagger*/
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.company.gas.controller"))
                //.paths(PathSelectors.ant("/lgd/**"))
                .build();
    }
    /*//多个分组
    @Bean
    public Docket docket2(){
        return new Docket(DocumentationType.SWAGGER_2).groupName("管理员");
    }
    */

    //配置Swagger信息=apiInfo
    private ApiInfo apiInfo(){
        //作者信息
        Contact contact = new Contact("Forth", "https://gitee.com/gascompany/gascompany", "2791843632@qq.com");

        return new ApiInfo(
                "迪的SwaggerAPI文档",
                "冲冲冲",
                "v1.0",
                "https://gitee.com/gascompany/gascompany",
                contact,
                "Apache 2.0",
                "http://www.apache.org/licenses/LICENSE-2.0",
                new ArrayList()
        );
    }

}
